package com.scuec.groupfive.controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import com.scuec.groupfive.service.CorrectStatisticsService;
import com.scuec.groupfive.vo.CorrectStatisticsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
//1
import java.util.List;
@CrossOrigin(origins = {"http://localhost:8081", "https://your-production-domain.com"},
        allowCredentials = "true")
@RestController
@RequestMapping("/api/correct-statistics")
public class CorrectStatisticsController {

    @Autowired
    private CorrectStatisticsService correctStatisticsService;

    @GetMapping("/trend")
    public List<CorrectStatisticsVO> getSubjectCorrectTrend(
            @RequestParam("userId") Integer userId,
            @RequestParam("subjectName") String subjectName,
            @RequestParam("year") Integer year,
            @RequestParam(value = "startMonth", required = false) Integer startMonth,
            @RequestParam(value = "endMonth", required = false) Integer endMonth
    ) {
        return correctStatisticsService.getSubjectCorrectTrend(userId, subjectName, year, startMonth, endMonth);
    }
}